<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" draggable :show-fullscreen="true" :width="900" destroy-on-close @closed="$emit('closed')">
        <el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="left">
            <el-form-item label="运营中心名" prop="name">
                <el-input v-model="form.name" clearable></el-input>
        	</el-form-item>
            <el-form-item label="后台ID" prop="admin_id">
                <el-input-number v-model="form.admin_id"></el-input-number>
        	</el-form-item>
            <el-form-item label="手机号" prop="mobile">
                <el-input v-model="form.mobile" clearable></el-input>
        	</el-form-item>
            <!-- <el-form-item label="创建时间" prop="createtime">
                <el-date-picker v-model="form.createtime" type="datetime"></el-date-picker>
        	</el-form-item>
            <el-form-item label="更新时间" prop="updatetime">
                <el-date-picker v-model="form.updatetime" type="datetime"></el-date-picker>
        	</el-form-item> -->
            <el-form-item label="密码" prop="password">
                    <el-input v-model="form.password" clearable></el-input>
        	</el-form-item>
            <el-form-item label="用户ID" prop="user_id">
                <!-- <el-input-number v-model="form.user_id"></el-input-number> -->
                <el-select v-model="form.user_id" clearable placeholder="用户">
                    <el-option   v-for="(item,index) in user_id_option" :key="index" :label="item.id+'👉'+item.nickname" :value="item.id"></el-option>
                </el-select>
        	</el-form-item>
            <el-form-item label="积分" prop="score">
                <el-input-number v-model="form.score"></el-input-number>
        	</el-form-item>



            <el-form-item label="消费总额占比%" prop="consume_total_ratio">
                <el-input-number v-model="form.consume_total_ratio"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业总额占比%" prop="trade_total_ratio">
                <el-input-number v-model="form.trade_total_ratio"></el-input-number>
        	</el-form-item>

            <!-- :addTemplate="addTemplate" -->
            <!-- <sc-form-table ref="table"   drag-sort placeholder="暂无数据">
						<el-table-column prop="consume_inc_ratio1" label="消费增长率1" width="85">
							<template #default="scope">
								<el-input v-model="scope.row.consume_inc_ratio1" placeholder="请输入内容"></el-input>
							</template>
						</el-table-column>
		
						<el-table-column prop="consume_inc_ratio2" label="消费增长率2" width="85">
							<template #default="scope">
								<el-input v-model="scope.row.consume_inc_ratio2" placeholder="请输入内容"></el-input>
							</template>
						</el-table-column>
						<el-table-column prop="consume_inc_ratio3" label="消费增长率3" width="85" align="center">
							<template #default="scope">
                                <el-input v-model="scope.row.consume_inc_ratio3" placeholder="请输入内容"></el-input>
							</template>
						</el-table-column>
						<el-table-column prop="consume_inc_ratio4" label="消费增长率4" width="85" align="center">
							<template #default="scope">
                                <el-input v-model="scope.row.consume_inc_ratio4" placeholder="请输入内容"></el-input>
							</template>
						</el-table-column>
            </sc-form-table> -->


    
                <el-row>
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="消费增长率1" prop="consume_inc_ratio1">
                            <el-input  v-model="form.consume_inc_ratio1" clearable></el-input>
                        </el-form-item>
                    </el-col>
            
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="消费增长率2" prop="consume_inc_ratio2">
                            <el-input  v-model="form.consume_inc_ratio2  " clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="消费增长率3" prop="consume_inc_ratio3">
                            <el-input  v-model="form.consume_inc_ratio3" clearable></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="消费增长率4" prop="consume_inc_ratio4">
                            <el-input  v-model="form.consume_inc_ratio4" clearable></el-input>
                        </el-form-item>
                    </el-col>   
                </el-row>

                <el-row>
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="发放占比1" prop="consume_send_ratio1">
                            <el-input  v-model="form.consume_send_ratio1" clearable></el-input>
                        </el-form-item>
                    </el-col>
            
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="发放占比2" prop="consume_send_ratio2">
                            <el-input  v-model="form.consume_send_ratio2  " clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="发放占比3" prop="consume_send_ratio3">
                            <el-input  v-model="form.consume_send_ratio3" clearable></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="发放占比4" prop="consume_send_ratio4">
                            <el-input  v-model="form.consume_send_ratio4" clearable></el-input>
                        </el-form-item>
                    </el-col>   
                </el-row>





                <el-row>
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="营业增长率1" prop="trade_inc_ratio1">
                            <el-input  v-model="form.trade_inc_ratio1" clearable></el-input>
                        </el-form-item>
                    </el-col>
            
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="营业增长率2" prop="trade_inc_ratio2">
                            <el-input  v-model="form.trade_inc_ratio2  " clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="营业增长率3" prop="trade_inc_ratio3">
                            <el-input  v-model="form.trade_inc_ratio3" clearable></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="营业增长率4" prop="trade_inc_ratio4">
                            <el-input  v-model="form.trade_inc_ratio4" clearable></el-input>
                        </el-form-item>
                    </el-col>   
                </el-row>

                <el-row>
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="发放占比1" prop="trade_send_ratio1">
                            <el-input  v-model="form.trade_send_ratio1" clearable></el-input>
                        </el-form-item>
                    </el-col>
            
                    <el-col :span="6"  class="light">
                        <el-form-item style="text-align:right"  label="发放占比2" prop="trade_send_ratio2">
                            <el-input  v-model="form.trade_send_ratio2  " clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="发放占比3" prop="trade_send_ratio3">
                            <el-input  v-model="form.trade_send_ratio3" clearable></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6"  class="dark">
                        <el-form-item style="text-align:right"  label="发放占比4" prop="trade_send_ratio4">
                            <el-input  v-model="form.trade_send_ratio4" clearable></el-input>
                        </el-form-item>
                    </el-col>   
                </el-row>
  
<!--   


            <el-form-item label="消费增长率1" prop="consume_inc_ratio1">
                <el-input v-model="form.consume_inc_ratio1" clearable></el-input>
        	</el-form-item>

            <el-form-item label="发放占比%" prop="consume_send_ratio1">
                <el-input-number v-model="form.consume_send_ratio1"></el-input-number>
        	</el-form-item>


            <el-form-item label="消费增长率2" prop="consume_inc_ratio2">
                <el-input v-model="form.consume_inc_ratio2" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="consume_send_ratio2">
                <el-input-number v-model="form.consume_send_ratio2"></el-input-number>
        	</el-form-item>
            <el-form-item label="消费增长率3" prop="consume_inc_ratio3">
                <el-input v-model="form.consume_inc_ratio3" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="consume_send_ratio3">
                <el-input-number v-model="form.consume_send_ratio3"></el-input-number>
        	</el-form-item>
            <el-form-item label="消费增长率4" prop="consume_inc_ratio4">
                <el-input v-model="form.consume_inc_ratio4" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="consume_send_ratio4">
                <el-input-number v-model="form.consume_send_ratio4"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业增长率1" prop="trade_inc_ratio1">
                <el-input v-model="form.trade_inc_ratio1" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="trade_send_ratio1">
                <el-input-number v-model="form.trade_send_ratio1"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业增长率2" prop="trade_inc_ratio2">
                <el-input v-model="form.trade_inc_ratio2" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="trade_send_ratio2">
                <el-input-number v-model="form.trade_send_ratio2"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业增长率3" prop="trade_inc_ratio3">
                <el-input v-model="form.trade_inc_ratio3" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="trade_send_ratio3">
                <el-input-number v-model="form.trade_send_ratio3"></el-input-number>
        	</el-form-item>
            <el-form-item label="营业增长率4" prop="trade_inc_ratio4">
                <el-input v-model="form.trade_inc_ratio4" clearable></el-input>
        	</el-form-item>
            <el-form-item label="发放占比%" prop="trade_send_ratio4">
                <el-input-number v-model="form.trade_send_ratio4"></el-input-number>
        	</el-form-item> -->
            <el-form-item label="推广额度阈值M" prop="extend_threshold">
                <el-input-number v-model="form.extend_threshold"></el-input-number>
        	</el-form-item>
            <el-form-item label="上月激励金发放比例" prop="last_month_excite_send_ratio">
                <el-input-number v-model="form.last_month_excite_send_ratio"></el-input-number>
        	</el-form-item>




        </el-form>
        <template #footer>
            <el-button @click="visible=false" >取 消</el-button>
            <el-button v-if="mode!='read'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
        </template>
    </el-dialog>
</template>

<script>
    
    export default {
        emits: ['success', 'closed'],
        
        data() {
            return {
                mode: "create",
                titleMap: {
                    read: '查看',
                    create: '新增',
                    update: '编辑',
                },
                visible: false,
                isSaveing: false,
                form: {
                    id: 0,
					name: '',
					admin_id: '',
					mobile: '',
					createtime: '',
					updatetime: '',
					password: '',
					user_id: '',
					score: '',
                    consume_total_ratio: '',
					trade_total_ratio: '',
					consume_inc_ratio1: '',
					consume_send_ratio1: '',
					consume_inc_ratio2: '',
					consume_send_ratio2: '',
					consume_inc_ratio3: '',
					consume_send_ratio3: '',
					consume_inc_ratio4: '',
					consume_send_ratio4: '',
					trade_inc_ratio1: '',
					trade_send_ratio1: '',
					trade_inc_ratio2: '',
					trade_send_ratio2: '',
					trade_inc_ratio3: '',
					trade_send_ratio3: '',
					trade_inc_ratio4: '',
					trade_send_ratio4: '',
					extend_threshold: '',
					last_month_excite_send_ratio: '',
                },
                rules: {
                },
                user_id_option:[],
            }
        },
        mounted() {
            this.getUser();
        },
        methods: {
            async getUser(){//需要加入的方法        
                var res = await this.$API.fa_user.read.get({page: 1,pageSize: 999999});
                this.user_id_option = res.data.list;
            },
            open(mode='create'){
                this.mode = mode;
                this.visible = true;
                return this
            },
            submit(){
                this.$refs.dialogForm.validate(async (valid) => {
                    if (valid) {
                        this.isSaveing = true;
                        var res = await this.$API.run[this.mode].post(this.form);
                        this.isSaveing = false;
                        if(res.code == 200){
                            this.$emit('success', this.form, this.mode)
                            this.visible = false;
                            this.$message.success(res.message)
                        }else{
                            this.$alert(res.message, "提示", {type: 'error'})
                        }
                    }else{
                        return false;
                    }
                })
            },
            setData(data){
                this.$TABLE.assign(this,data);
            }
        }
    }
</script>